package com.shop2cn.iapi.wxcomponent.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.wxcomponent.parameter.ConfimPayChannelStatusBean;
import com.shop2cn.iapi.wxcomponent.service.ConfimPayChannelStatusCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.Mchapp;
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
/**
*小程序支付通道上线
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_ConfimPayChannelStatus{
	private static ConfimPayChannelStatusBean confimpaychannelstatusBean;
	private static ConfimPayChannelStatusCall confimpaychannelstatusCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("小程序支付通道上线");
	}

	@Before
	public void caseUp() {
		confimpaychannelstatusBean=new ConfimPayChannelStatusBean();
		confimpaychannelstatusCall=new ConfimPayChannelStatusCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(confimpaychannelstatusCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ConfimPayChannelStatus_001() {
		Logger.start(true,"小程序支付通道上线");
		try {
			//支付通道：0-待审核， 1-审核中，2-已上线，3-审核失败，4-返回修改
			//TODO 追加全流程
			confimpaychannelstatusBean.setMchId(2004);
			confimpaychannelstatusCall.setData(confimpaychannelstatusBean);
			confimpaychannelstatusCall.callService();			
			Logger.verifyEquals("200", confimpaychannelstatusCall.getString("code"), "验证返回code");
			Mchapp mch = new DefGodMchWapper().selectMchappByExample(confimpaychannelstatusBean.getMchId()).get(0);
			Logger.verifyEquals(2, mch.getPayChannelStatus(), "验证PayChannelStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ConfimPayChannelStatus_002() {
		Logger.start(true,"不输入mchid失败");
		try {
//			confimpaychannelstatusBean.setMchId(0);
			confimpaychannelstatusCall.setData(confimpaychannelstatusBean);
			confimpaychannelstatusCall.callService();			
			Logger.verifyEquals("400", confimpaychannelstatusCall.getString("code"), "验证返回code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ConfimPayChannelStatus_003() {
		Logger.start(true,"输入错误MchId失败");
		try {
			confimpaychannelstatusBean.setMchId(0);
			confimpaychannelstatusCall.setData(confimpaychannelstatusBean);
			confimpaychannelstatusCall.callService();			
			Logger.verifyEquals("400", confimpaychannelstatusCall.getString("code"), "验证返回code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}